//
//  ByCellMineNormal.m
//  mijifen_ios
//
//  Created by 朱凯 on 2017/10/20.
//  Copyright © 2017年 itboye. All rights reserved.
//

#import "ByCellMineNormal.h"

@implementation ByCellMineNormal
{
    UIImageView *_iconView;
    UILabel *_titleLabel;
    UILabel *_subTitleLabel;
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
     
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self setupUI];
    }
    return self;
}

- (void)setupUI {
    
    // 线条
    UIView *line = [UIView new];
    line.backgroundColor = BY_LINE_COLOR;
    [self.contentView addSubview:line];
    [line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.bottom.equalTo(self);
        make.height.equalTo(@1);
    }];
    
    
    // 图标
    _iconView = [UIImageView new];
    [self.contentView addSubview:_iconView];
    [_iconView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_offset(CGSizeMake(30, 30));
        make.left.equalTo(self).offset(15);
        make.centerY.equalTo(self);
    }];
    
    // 标题
    _titleLabel = [[UILabel alloc] init];
    _titleLabel.adjustsFontSizeToFitWidth = true;
    _titleLabel.numberOfLines = 1;
    _titleLabel.text = @"title";
    _titleLabel.font = FONT(16);
    _titleLabel.textAlignment = NSTextAlignmentLeft;
    _titleLabel.textColor = [UIColor blackColor];
    [self.contentView addSubview:_titleLabel];
    [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_iconView.mas_right).offset(10);
        make.width.equalTo(self).multipliedBy(0.5);
        make.top.height.equalTo(self);
    }];
    
    // 箭头
    UIImageView *arrowView = [UIImageView new];
    arrowView.image = [UIImage imageNamed:@"右箭头"];
    [self.contentView addSubview:arrowView];
    [arrowView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_offset(CGSizeMake(20, 20));
        make.right.equalTo(self).offset(-5);
        make.centerY.equalTo(self);
    }];
    
    // 子标题
    _subTitleLabel = [[UILabel alloc] init];
    _subTitleLabel.adjustsFontSizeToFitWidth = true;
    _subTitleLabel.numberOfLines = 1;
    _subTitleLabel.text = @"";
    _subTitleLabel.font = FONT(16);
    _subTitleLabel.textAlignment = NSTextAlignmentRight;
    _subTitleLabel.textColor = [UIColor lightGrayColor];
    [self.contentView addSubview:_subTitleLabel];
    [_subTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_titleLabel.mas_right).offset(10);
        make.right.equalTo(arrowView.mas_left).offset(-5);
        make.top.height.equalTo(self);
    }];
}

- (void)setTitle:(NSString *)title {
    
    _title = title;
    _titleLabel.text = title;
}
- (void)setSubTitle:(NSString *)subTitle {
    
    _subTitle = subTitle;
    _subTitleLabel.text = subTitle;
}
- (void)setIconImageName:(NSString *)iconImageName {
    
    _iconImageName = iconImageName;
    _iconView.image = [UIImage imageNamed:iconImageName];
}
@end
